<?php

class CCustomWebUser extends CWebUser
{
    public function login($identity, $duration = 0)
    {
        $user = $identity->getUser();
        $user->save();

        parent::login($identity, $duration);    
    }
    
    public function isGuest()
    {
        return $this->getIsGuest();
    }
    
    public function isAdmin()
    {
        return Yii::app()->authManager->getAuthAssignment('administrator', $this->id);
    }
    
    public function isUser()
    {
        return Yii::app()->authManager->getAuthAssignment('user', $this->id);
    }

    public function isUserSoleProprietorship()
    {
        return Yii::app()->authManager->getAuthAssignment('user_sole_proprietorship', $this->id);
    }
}